#ifndef _FREEDO_DATABASE_OPTIONS_
#define _FREEDO_DATABASE_OPTIONS_

#include "node.h"
#include "v8.h"
#include "uv.h"
#include <string>

#undef WINAPI_FAMILY

#include "udataset/mdb/CommonStruct.h"
#include "udataset/mdb//ModelTree.h"
#include "connectionoptions.h"
#include "taskoptions.h"

using namespace v8;
using namespace std;

namespace freedatabase
{

/**
		 * 导入XML文件
		 * */
class ImportorOptions
{
public:
	Persistent<Function> percent;
	Persistent<Function> finish;

	uv_async_t main_async;
	uv_work_t work_pool;

	double scale;
	ConnectionOptions *connopts;
	string author;
	string modelname;
	string pmodelfolder;
	bool ok;
	string msg;

public:
	ImportorOptions(){};
	~ImportorOptions(){};
};
/**
		 * 数据库链接
		 * */
class DatabaseOptions
{
public:
	Persistent<Function> finish;
	uv_work_t work_pool;
	ConnectionOptions *connopts;
	bool ok;
	string msg;

public:
	DatabaseOptions(){};
	~DatabaseOptions(){};
};

/**
		 * pModelInfo
		 * */
class PModelInfoOptions
{
public:
	Persistent<Function> finish;
	uv_work_t work_pool;
	PModelInfoVec infovec;
	uint32 pagenumber;	// 页数
	uint32 pagecount;		// 每页记录的条数
	uint32 totalnumber; // 记录总数
	bool ok;
	string msg;

public:
	PModelInfoOptions(){};
	~PModelInfoOptions(){};
};

/**
		* pModel
		* */
class PModelOptions
{
public:
	Persistent<Function> finish;
	uv_work_t work_pool;
	uint32 modelID;		// 模型ID
	string modelName; // 模型名称
	bool ok;
	string msg;

public:
	PModelOptions(){};
	~PModelOptions(){};
};

/**
		* Auth
		* */
class AuthOptions
{
public:
	Persistent<Function> finish;
	uv_work_t work_pool;
	uint32 modelID; // 模型ID
	string author;	// 用户
	bool accessed;	// 是否有访问权限
	bool ok;
	string msg;

public:
	AuthOptions(){};
	~AuthOptions(){};
};

/**
		* TreeNode
		* */
class TreeNodeOptions
{
public:
	Persistent<Function> finish;
	uv_work_t work_pool;
	uint32 modelID;			// 模型ID
	string parentGuid;	// 父级ID
	string guid;				// 节点ID
	uint32 tileNo;			//
	uint32 pagenumber;	// 页码
	uint32 pagecount;		// 每页个数
	uint32 totalnumber; // 记录总数
	ModelTree *treeNode;
	ModelTreeVec treeNodeVec;
	bool ok;
	string msg;

public:
	TreeNodeOptions(){};
	~TreeNodeOptions(){};
};

/**
 * 构件属性
 * 构件属性这几个查询接口中用到的变量都写到这一个结构里了
* */
class ComponentOptions
{
public:
	Persistent<Function> finish;
	uv_work_t work_pool;
	uint32 modelID; // 模型ID
	string guid;		// 构件的ID
	string setid;		// 属性集合ID
	string propKey; // 属性查询：Key
	string propVal; // 属性查询： Value
	string tag;			// tag 属性查询时使用
	CompAttr attr;
	CompInfoVec infoVec;
	uint32 pagecount;		 // 用于分页属性查询
	uint32 pagenumber;	 // 分页属性查询
	uint32 totalnumber;	// 总数
	CompTypeVec typeVec; // 构件type
	uint32 compTypeId;	 // 构件ID
	bool ok;
	string msg;

public:
	ComponentOptions(){};
	~ComponentOptions(){};
};

/**
 * AsyncTaskOptions
* */
class AsyncTaskOptions
{
public:
	Persistent<Function> finish;
	uv_work_t work_pool;
	uint32 modelID;			// 模型ID
	uint32 taskID;			// 任务ID
	uint32 pagecount;		// 用于分页属性查询
	uint32 pagenumber;	// 分页属性查询
	uint32 totalnumber; // 总数
	TaskVec tasks;			// 任务查询结果
	TaskOptions *opts;	// 任务选项
	bool ok;
	string msg;

public:
	AsyncTaskOptions(){};
	~AsyncTaskOptions(){};
};

/**
 * FloorsOptions
* */
class FloorsOptions
{
public:
	Persistent<Function> finish;
	uv_work_t work_pool;
	uint32 modelID;				// 模型ID
	uint32 floorID;				// 楼层ID
	Floors floors;				// 楼层信息
	uint32 pagecount;			// 用于分页属性查询
	uint32 pagenumber;		// 分页属性查询
	uint32 totalnumber;		// 总数
	CompInfoVec compInfo; // 构件信息
	bool ok;
	string msg;

public:
	FloorsOptions(){};
	~FloorsOptions(){};
};

} // namespace freedatabase

#endif // !_FREEDO_DATABASE_OPTIONS_